﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.BodyMeasureModelCommand;
using IntelligentAgriculture.WebAPI.Application.Command.BreedingWeighCommand;
using IntelligentAgriculture.WebAPI.Application.CommandHandler.BreedingWeighCommandHandler;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.BodyMeasureModelCommandHandler
{
    public class BodyMeasureModelCreateCommandHandler : IRequestHandler<BodyMeasureModelCreateCommand, Results<int>>
    {



        private readonly IBodyMeasureModelService bodymeasureService;
        private readonly ILogger<BodyMeasureModelCreateCommandHandler> logger;
        public BodyMeasureModelCreateCommandHandler(IBodyMeasureModelService bodymeasureService, ILogger<BodyMeasureModelCreateCommandHandler> logger)
        {
            this.bodymeasureService = bodymeasureService;
            this.logger = logger;
        }

        public async Task<Results<int>> Handle(BodyMeasureModelCreateCommand request, CancellationToken cancellationToken)
        {
            var result = new Bodymeasuremodel()
            {
               
                EarTag = request.EarTag,
                MeasureDate = request.MeasureDate,
                Height = request.Height,
                BodyLength = request.BodyLength,
                Chest = request.Chest,
                Tube = request.Tube,
                Oschea = request.Oschea,
                Backfat = request.Backfat,
                EyeMuscleArea = request.EyeMuscleArea,
                EyeMuscleWidth = request.EyeMuscleWidth,
            };
            var list = await bodymeasureService.Add(result);
            return Results<int>.DataResult(list);
        }




    }





}
